<?php
declare(strict_types=1);
namespace SixShop\Lakala\Controller\Admin;

use SixShop\Core\Request;
use SixShop\Lakala\Entity\LakalaWechatPaymentEntity;
use SixShop\Lakala\Service\PaymentRecordService;
use think\Response;
use function SixShop\Core\page_response;
use function SixShop\Core\success_response;

class TradeOrderController
{
    public function index(Request $request, PaymentRecordService $service): Response
    {
        $params = $request->get([
            'order_sn/s' => '',
            'out_trade_no/s' => '',
            'transaction_id/s' => '',
            'wechat_transaction_id/s' => '',
        ]);
        return page_response(page: $service->getTradeOrderList($params, $request->pageAndLimit()));
    }

    public function updateExpressCompany(int $id, Request $request, LakalaWechatPaymentEntity $lakalaWechatPaymentEntity): Response
    {
        $expressCompany = $request->put('express_company/s');
        return success_response($lakalaWechatPaymentEntity->update(
            ['express_company' => $expressCompany],
            ['id' => $id]
        ));
    }
}